<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr" :key="index">{{item}} <button @click="btn(index)">删除</button></li>
    </ul>
    <button @click="fn">添加</button>
  </div>
</template>

<script>
export default {
data () {
  return {
    arr:[1]
  }
},
methods: {
    fn(){
     let n=parseInt(Math.random()*(30-1)+1)
     this.arr.push(n)
    },
    btn(index){
      this.arr.splice(index,1)
    }
  }
}
</script>

<style>

</style>